#ifndef _CAN_H
#define _CAN_H

typedef struct can_t {
  tt_object_t obj;
} can_t;

typedef struct can_message_t {
  uint16_t	id;
  uint8_t	length;
  uint8_t	data[8];
} can_message_t;

typedef struct can_listener_t {
  tt_object_t	*obj;
  tt_method_t	method;
  env_time_t	deadline;
  uint16_t		id;
  uint16_t		id_mask;
  can_message_t msg;
} can_listener_t;

extern can_t can;

void		canInit(can_t *self, void *none);
uint16_t	canSend(can_t *self, can_message_t *msg);
uint16_t	canInstall(can_t *self, can_listener_t **listener);


#define CAN_OK         0
#define CAN_FAIL      -1
#define CAN_OUT_OF_MB -2
#define LISTENERS 6

#endif
